import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-02-10
 * Time: 19:18
 */
//整个程序的入口
public class Main {
    public static User login(){
        System.out.println("请输入你的姓名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入你的身份（1.表示管理员，0.表示普通用户）");
        int choice = scanner.nextInt();
        if(choice==1){
            /*  向上转型
            User user = new AdminUser(name);
            return user;*/
            return new AdminUser(name);
        }else {
            /*   向上转型
            User user = new NormalUser(name);
            return user;*/
            return new NormalUser(name);
        }
    }
    public static void main(String[] args) {
        //图书的基本数据实例化
        BookList bookList = new BookList();
        //创建用户，调用登录方法
        User user = login(); //向上转型

        //循环
        while (true){
            int choice = user.Menu(); //动态绑定

            //根据 choice 选择合适的操作
            user.doWork(choice,bookList);
        }
    }
}
